<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="text" id="text">
  <button class="but">发送</button>
  <ul></ul>
</body>
<script src="socket.io/socket.io.js"></script>
<script>
  var socket = io('http://172.17.32.166:3000/');
  var but = document.querySelector('.but')
  var ul = document.querySelector('ul')
  var text = document.querySelector('#text')
  text.value = 5555
  but.addEventListener('click', function () {
    var li = document.createElement("li")
    socket.emit('haha', { text: text.value })
    socket.on('send', data => {
      ul.lastChild.innerHTML = data.text
    })
    ul.appendChild(li)
  })
</script>

</html>